/// <summary>
/// 单例模式,微软官方推荐写法
/// </summary>
public class SingletonRecommend
{
  private static volatile SingletonRecommend _Singleton = null;
  private static object _lock = new();

  private SingletonRecommend() { }

  public SingletonRecommend CreateInstance()
  {
    if (_Singleton == null)
    {
      lock (_lock)
      {
        if (_Singleton == null)
        {
          _Singleton = new SingletonRecommend();
        }
      }
    }
    return _Singleton;
  }
}